


@extends("admin.base")
@section("page")
    <html>
    <style>
        @font-face {
            font-family: "ALKATIP Asliya";
        }
    </style>
    <body>
    <h1 align="center">管理页面</h1>
    <div class="row col-12">
            <div class="card">
                <div class="card-body">
                    <a href="typesaddpage"><button class="btn-primary " style="width: 50px;height: 30px">添加</button></a>

                    <div class="table-responsive">
                        <table class="table mb-0" style="text-align: center;font-family: 'ALKATIP Asliya'" align="center" >
                            <tr>
                                <td>id</td>
                                <td>中文名称</td>
                                <td>维吾尔文名称</td>
                                <td>排序</td>
                                <td>created_at</td>
                                <td>updated_at</td>
                                <td>操作</td>



                            @foreach($types as $tp)
                            <tr class="table-success">
                                <td scope="row">{{$tp->id}}</td>
                                <td>{{$tp->name_ch}}</td>
                                <td>{{$tp->name_uy}}</td>
                                <td>{{$tp->order}}</td>
                                <td>{{$tp->created_at}}</td>
                                <td>{{$tp->updated_at}}</td>
                                <td>
                                    <a href="typesaddpage?id={{$tp->id}}"><button style="background-color: orangered;border: none;border-radius: 5px;height: 30px;width: 50px;outline: none;">编辑</button></a>
                                    <a><button onclick="del({{$tp->id}})" style="background-color: orangered;border: none;border-radius: 5px;height: 30px;width: 50px;outline: none;">删除</button></a>

                                </td>
                            </tr>
                                @endforeach
                        </table>

                    </div>

                </div>
            </div>
        </div>
    </body>
    </html>
@endsection
<style>
    .swal-footer {
        text-align: center;
        padding-top: 13px;
        margin-top: 13px;
        padding: 13px 16px;
        border-radius: inherit;
        border-top-left-radius: 0;
        border-top-right-radius: 0;
    }
</style>
@section("scripts")
    <script>
        function del(id) {
            swal({
                title: "确认操作",
                text: "如果数据被删除，无法恢复，确认删除吗",
                icon: "warning",
                buttons: ["取消", "删除"],
            }).then((willDelete) => {
                if (willDelete) {
                    $.ajax({
                        url:"http://dil.aynakedu.com/delete",    //请求的url地址
                        dataType:"json",   //返回格式为json
                        async:true,//请求是否异步，默认为异步，这也是ajax重要特性
                        headers:{'X-CSRF-TOKEN':'{{csrf_token()}}' },
                        data: {"id":id},    //参数值
                        type:"GET",   //请求方式
                        success:function(req){
                            if(req.err == 0){
                                swal({
                                    title: "操作成功",
                                    text: req.title,
                                    icon: "success",
                                    button: "知道了",
                                });
                                setTimeout(function (){
                                    location.reload();
                                },2000)
                            }
                        },
                        error:function(err){
                            //请求出错处理
                        }
                    });
                }else{

                }
            });
        }
    </script>
@endsection
